package stdlib.javax.swing

import java.awt.BorderLayout
import java.awt.Dimension
import java.awt.Font
import java.awt.Rectangle
import javax.swing.*

class Quick {
    fun create() {
        val frame = JFrame("hello swing").apply {
            defaultCloseOperation = JFrame.EXIT_ON_CLOSE
            bounds = Rectangle(100, 100, 100, 100)
            isVisible = true
            layout = BorderLayout()
            contentPane = JPanel().apply {
                add(JLabel().apply {
                    size = Dimension(100, 50)
                    text = "this is a label,这是一个标签"
                    font = Font("楷书", Font.BOLD, 20)
                })
                add(JButton().apply {
                    text = "我是一个按钮"
                    addActionListener {
                        println("click")
                    }
                })
            }
        }
        frame.pack()
    }
}

fun main() {
    SwingUtilities.invokeLater(Quick()::create)
}